function func(params) {
    let keyArr = []
    let returnArr = []
    let disburse = 0//支出
    let income = 0//收入
    params.map((item,index)=>{//获取全部时间
        keyArr.push(item.addTime)
        console.log(item)
        if(item.bill_type==1){//支出
            disburse+=Number(item.amount)
        }else if(item.bill_type==2){
            income+=Number(item.amount)
        }
    })
    keyArr = [...new Set(keyArr)]//时间去重

    keyArr.map((item,index)=>{//时间遍历 
        returnArr.push({
            time:'',
            week:'',
            count:0,
            list:[]
        })
        returnArr[index].time = item
        let shou = 0;
        let zhi = 0;
        params.map((ite,ind)=>{
            if(item==ite.addTime){
                if(ite.bill_type==1){//支出
                    zhi+=Number(ite.amount)
                }else if(ite.bill_type==2){
                    shou+=Number(ite.amount)
                }
                returnArr[index].week = weekTransChinese(ite.time_for_week)
                returnArr[index].list.push(ite)
            }
        })
        returnArr[index].count = shou-zhi
    })


    return {
        disburse,
        income,
        list:returnArr
    }
}
function weekTransChinese(param){
    if(param=='1'){
        return '星期一'
    }
    if(param=='2'){
        return '星期二'
    }
    if(param=='3'){
        return '星期三'
    }
    if(param=='4'){
        return '星期四'
    }
    if(param=='5'){
        return '星期五'
    }
    if(param=='6'){
        return '星期六'
    }
    if(param=='7'){
        return '星期日'
    }
}
module.exports = func